@layout("/common/_container.html"){
<div class="layui-card">
	<div class="layui-form layui-card-header layuiadmin-card-header-auto">
	  <div class="layui-form-item">
	    <div class="layui-inline">
	      	<label class="layui-form-label">开始时间</label>
			<div class="layui-input-block">
			  <input type="text" id="beginTime" id="beginTime" autocomplete="off" class="layui-input">
			</div>
	    </div>
	    <div class="layui-inline">
	      	<label class="layui-form-label">结束时间</label>
			<div class="layui-input-block">
			  <input type="text" id="endTime" id="endTime" autocomplete="off" class="layui-input">
			</div>
	    </div>
	    <div class="layui-inline">
	      	<label class="layui-form-label">日志名称</label>
			<div class="layui-input-block">
			   <input type="text" id="logName" id="logName" placeholder="日志名称"  autocomplete="off" class="layui-input">
			</div>
	    </div>
	    <div class="layui-inline">
	      	<label class="layui-form-label">日志类型</label>
			<div class="layui-input-inline">
				<select name="logType" id="logType">
			        <option value="0">全部</option>
                    <option value="1">业务日志</option>
                    <option value="2">异常日志</option>
			    </select>
			</div>
	    </div>
	    <div class="layui-inline">
	      <button class="layui-btn layuiadmin-btn-useradmin" data-type="reload">
	        <i class="layui-icon layui-icon-search layuiadmin-button-btn"></i>
	      </button>
	    </div>
	  </div>
	</div>
  <div class="layui-card-body">
  @if(shiro.hasPermission("/log/delLog")){
  <div style="padding-bottom: 10px;">
      <button class="layui-btn layui-btn-danger layuiadmin-btn-useradmin" data-type="del"><i class="layui-icon layui-icon-delete"></i>清空日志</button>
  </div>
  @}
  <table class="layui-hidden" id="table" lay-filter="table"></table>
  	<script type="text/html" id="oper">
  		<a class="layui-btn layui-btn-normal layui-btn-xs" lay-event="edit" title="查看详情"><i class="layui-icon layui-icon-file-b"></i></a>
	</script>
  </div>
</div>

<script>
layui.config({
	base: '${ctxPath}/static/layuiadmin/' //静态资源所在路径
}).extend({
	index: 'lib/index' //主入口模块
}).use(['index', 'layer','table', 'form','laydate'],function(){
	
	var $ = layui.$
  	,form = layui.form
  	,table = layui.table
  	,laydate = layui.laydate;
	laydate.render({
        elem: '#beginTime'
        ,showBottom: false
    });
	laydate.render({
        elem: '#endTime'
        ,showBottom: false
    });
	var loadingIndex = layer.msg('数据加载中', {icon: 16, time: 0 });
	table.render({
	    elem: '#table'
	    ,url: Feng.ctxPath +'/operLog/list'
	    ,cellMinWidth: 100
	    ,height: 'full-210' //设置高度
	    ,cols: [[
	        {title: '日志类型', field: 'logtype'},
	        {title: '日志名称', field: 'logname'},
	        {title: '管理员名称', field: 'adminName'},
	        {title: '类名', field: 'classname'},
	        {title: '方法名', field: 'method'},
	        {title: '时间', field: 'createtime'},
	        {title: '操作',fixed: 'right', width:80, align:'center',fixed: 'right', toolbar: '#oper'}
	    ]]
	    ,page:true
	    ,loading:true
	    ,text: '对不起，加载出现异常！'
	    ,done: function(res){
	    	layer.close(loadingIndex);
        }
	});
	
	//事件
	var active = {
		//加载
	   	reload: function(){
	       var beginTime = $('#beginTime').val();
	       var endTime = $('#endTime').val();
	       var logName = $('#logName').val();
	       var logType = $('#logType').val();
	       var loadingIndex = layer.msg('数据加载中', {icon: 16, time: 0 });
	       //执行表格重载
	       table.reload('table', {
	    	 height: 'full-210' //设置高度
	    	 ,where: {
	    		 beginTime: beginTime,
	    		 endTime:endTime,
	    		 logName:logName,
	    		 logType:logType
	         }
	       ,page:true
	       ,done: function(res){
		    	layer.close(loadingIndex);
	        }
	      });
	    },
	    del: function(){
     	 layer.confirm('是否清空所有日志?', function(index){
             var loadingIndex = layer.msg('数据加载中', {icon: 16, time: 0 ,shade: 0.01});
   		 	var ajax = new $ax(Feng.ctxPath + "/operLog/delLog", function (data) {
                Feng.success("清空成功!");
                table.reload('table'); //数据刷新
                layer.close(loadingIndex); //关闭弹层
                layer.close(index); //关闭弹层
            }, function (data) {
                Feng.error("清空失败!" + data.responseJSON.message + "!");
                layer.close(loadingIndex); //关闭弹层
            },true);
            ajax.start();
        });
       }
   };
  
   
   $('.layui-btn.layuiadmin-btn-useradmin').on('click', function(){
     var type = $(this).data('type');
     active[type] ? active[type].call(this) : '';
   });
	
 //监听工具条
   table.on('tool(table)', function(obj){
     var data = obj.data;
     if(obj.event === 'edit'){
         var loadingIndex = layer.msg('数据加载中', {icon: 16, time: 0});
  	   var ajax = new $ax(Feng.ctxPath + "/operLog/detail/" + data.id, function (data) {
  		 layer.open({
		  type: 1,
		  area: ['720px', '445px'], //宽高
		  content: data.regularMessage
		});
       }, function (data) {
           Feng.error("获取详情失败!");
       },true);
       ajax.start();
     }
   });
});
</script>
@}
